﻿namespace TetrisProject.GameObjects.Blocks
{
    using System;

    public class BlockT : GameObject
    {
        private enum Direction { NORTH, EAST, SOUTH, WEST };

        private static bool[,] imageNorth = new bool[,] 
        {
            { true,  true, true },
            { false, true, false }
        };

        private static bool[,] imageWest = new bool[,] 
        {
            { true, false },
            { true, true },
            { true, false }
        };

        private static bool[,] imageSouth = new bool[,] 
        {
            { false, true, false },
            { true, true, true   }
        };

        private static bool[,] imageEast = new bool[,] 
        {
            { false, true },
            { true,  true },
            { false, true }
        };

        private Direction currentDirection;

        public BlockT(int coordY)
            : base(coordY, imageNorth)
        {
            this.currentDirection = Direction.NORTH;
        }

        public override void Rotate()
        {
            switch (this.currentDirection)
            {
                case Direction.NORTH:
                    this.body = BlockT.imageWest;
                    this.currentDirection = Direction.WEST;
                    break;
                case Direction.WEST:
                    this.body = BlockT.imageSouth;
                    this.currentDirection = Direction.SOUTH;
                    break;
                case Direction.SOUTH:
                    this.body = BlockT.imageEast;
                    this.currentDirection = Direction.EAST;
                    break;
                case Direction.EAST:
                    this.body = BlockT.imageNorth;
                    this.currentDirection = Direction.NORTH;
                    break;
            }
        }
    }
}
